package com.midian.action.mc.activity;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;
import javax.persistence.ManyToOne;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.midian.action.mc.common.AjaxAction;
import com.midian.common.annotation.FunctionAnnotationOverride;
import com.midian.common.exception.BizException;
import com.midian.model.activity.ActivityCommentPic;
import com.midian.model.pic.Pic;
import com.midian.model.user.User;
import com.midian.service.activity.IActivityCommentPicService;

/**
 * 图书评论Action
 * @author Mengfh
 *
 */
@Scope("prototype")
@Controller("activityCommentPicAction")
@FunctionAnnotationOverride(isAction = true, auth = "评论图集管理")
public class ActivityCommentPicAction extends AjaxAction<ActivityCommentPic> {
	/**图书评论实体*/
	private ActivityCommentPic entity;
	/**图书评论实体列表*/
	private List<ActivityCommentPic> rows;
	/**图书评论业务*/
	private IActivityCommentPicService activityCommentPicService;
	
//	private List<String> accountList;
	
	private List<String> picList = new ArrayList<String>();
//	
//	private List<Map<String, Object>> list;
//	
//	private Map<String, Object> map;
//	
//	private String idd;
	
	
//	public String getIdd() {
//		return idd;
//	}
//	public void setIdd(String idd) {
//		this.idd = idd;
//	}
//	public Map<String, Object> getMap() {
//		return map;
//	}
//	public void setMap(Map<String, Object> map) {
//		this.map = map;
//	}
//	public List<Map<String, Object>> getList() {
//		return list;
//	}
//	public void setList(List<Map<String, Object>> list) {
//		this.list = list;
//	}
//	public List<String> getAccountList() {
//		return accountList;
//	}
//	public void setAccountList(List<String> accountList) {
//		this.accountList = accountList;
//	}
	public List<String> getPicList() {
		return picList;
	}
	public void setPicList(List<String> picList) {
		this.picList = picList;
	}
	public ActivityCommentPic getEntity() {
		return entity;
	}
	public void setEntity(ActivityCommentPic entity) {
		this.entity = entity;
	}
	@Resource(name = "activityCommentPicService")
	public void setActivityCommentPicService(IActivityCommentPicService activityCommentPicService) {
		this.service = activityCommentPicService;
		this.activityCommentPicService = activityCommentPicService;
	}
	@Override
	protected ActivityCommentPic dytEntity() {
		if(this.entity == null) {
			this.entity = new ActivityCommentPic();
		}
		return getEntity();
	}
	@Override
	protected void dyEntity(ActivityCommentPic t) {
		setEntity(t);
	}
	@Override
	public void setRows(List<ActivityCommentPic> rows) {
		this.rows = rows;
	}
	@Override
	public List<ActivityCommentPic> getRows() {
		return rows;
	}
	
	@Override
	public String showInfo() {
		StringBuilder sql = new StringBuilder("select u.account,p.id from activity_comment_pic acp"
				+" LEFT JOIN activity_comment ac on acp.commentId=ac.id"
				+" LEFT JOIN user u on ac.userId = u.id"
				+" LEFT JOIN pic p on acp.picId = p.id"
				+" where u.account=18993399470");
		try {
			List list = this.activityCommentPicService.getResultsBysql(sql.toString());
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> resultMap = (Map<String, Object>) list.get(i);
				String picid = (String) resultMap.get("id");
				System.out.println("--------wert------"+picid);
				picList.add(picid);
			}
			
		} catch (BizException e) {
			e.printStackTrace();
		}
		return super.showInfo();
	}
	public ActivityCommentPicAction() {
		super();
		// TODO Auto-generated constructor stub
	}
		
//	//TODO showlist评论列表代做
//	@Override
//	public String ajax() {
//		StringBuilder sql = new StringBuilder("select u.account,p.id from activity_comment_pic acp"
//		+" LEFT JOIN activity_comment ac on acp.commentId=ac.id"
//		+" LEFT JOIN user u on ac.userId = u.id"
//		+" LEFT JOIN pic p on acp.picId = p.id"
//		+" where u.account=18993399470");
//		
//		try {
//			map = (Map<String, Object>) this.activityCommentPicService.getResultsBysql(sql.toString());
//			System.out.println(map);
////			System.out.println(list);
////			
////			for (Map<String, Object> map : list) {
////				Set<String> keySet = map.keySet();
////				Iterator<String> it = keySet.iterator();
////				while (it.hasNext()) {
////					String account = it.next();
////					String picId=(String) map.get(account);
////					System.out.println(account+"-------"+picId);
//////					accountList.add(account);
//////					picList.add(picId);
////				}
////			}
////			for (int i = 0; i < list.size(); i++) {
////				
////				
////				Map<String, Object> map = list.get(i);
////				map.get("key");
////				
////			}
//				
////				User user = (User) map.get(0);
////				Pic pic =(Pic)map.get(1);
////				userList.add(user);
////				picList.add(pic);
//						
//		} catch (BizException e) {
//			e.printStackTrace();
//		}
//		return super.showList();
//	}
	
	
}
